<yandex>
    <clickhouse_remote_servers>
        <default>
            {% for host in groups.clickhouse_servers -%}
                <shard>
                    <weight>1</weight>
                    <internal_replication>true</internal_replication>
                    <replica>
                        <host>{{ host }}</host>
                        <port>{{ hostvars[host].clickhouse_tcp_port }}</port>
                        <password>{{ clickhouse_default_password }}</password>
                    </replica>
                </shard>
            {% endfor -%}
        </default> 
    </clickhouse_remote_servers>
    
    <!-- zookeeper 配置 -->
    <zookeeper_servers>
        {% for host in groups.zookeeper_servers -%}
            <node index="{{ loop.index }}">
                <host>{{ host }}</host>
                <port>2181</port>
            </node>
        {% endfor -%}
    </zookeeper_servers>
    
    <!-- macros配置 -->
    <macros>
        {% set current_host = ansible_host -%}
        {% for host in groups.clickhouse_servers -%}
            {%- if host == current_host -%}
                <shard>0{{ loop.index }}</shard>
                <replica>{{ current_host }}</replica> 
            {% endif %}
        {% endfor -%}
    </macros>
    
    <networks>
        <ip>::/0</ip>
    </networks>
    
    <clickhouse_compression>
        <case>
            <min_part_size>10000000000</min_part_size>
            <min_part_size_ratio>0.01</min_part_size_ratio>
            <method>lz4</method>
        </case>
    </clickhouse_compression>
</yandex>